Skip to content

Conversation

EmrysMyrddin
Copy link
Collaborator

No description provided.

@EmrysMyrddin EmrysMyrddin force-pushed the repro/otel/bad-validation-error-handling branch from 529318e to 627a488 Compare September 23, 2025 19:20
@EmrysMyrddin EmrysMyrddin changed the title added test for validation errors fix(opentelemetry): attributes missing on validation errors Sep 23, 2025
@EmrysMyrddin EmrysMyrddin marked this pull request as ready for review September 23, 2025 19:39
@Copilot Copilot AI review requested due to automatic review settings September 23, 2025 19:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes missing attributes on validation errors in OpenTelemetry spans by restructuring how GraphQL operation attributes are set during different phases of query processing.

Key changes:

  • Refactored attribute setting to ensure operation metadata is available during validation errors
  • Added proper error code collection and attribute setting for validation spans
  • Enhanced test coverage for validation error scenarios with Hive tracing

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/plugins/opentelemetry/tests/utils.ts Updates test utilities to support custom tracer providers and switches from proxy to supergraph configuration
packages/plugins/opentelemetry/tests/useOpenTelemetry.spec.ts Adds validation error test case and updates existing tests for new supergraph setup
packages/plugins/opentelemetry/src/spans.ts Refactors attribute setting functions and adds operation caching mechanism
packages/plugins/opentelemetry/src/plugin.ts Updates plugin hooks to properly set attributes during validation and execution phases
e2e/opentelemetry/opentelemetry.e2e.ts Adds focused end-to-end test for validation error telemetry
e2e/opentelemetry/gateway.config.ts Adds alternative configuration setup for testing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 801 to 803
operationSpan.span.attributes['graphql.operation.name'] === 'test';
operationSpan.span.attributes['graphql.operation.type'] === 'query';
operationSpan.span.attributes['hive.graphql.error.count'] === 1;
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are using assignment operators (===) instead of assertions. They should use expect() assertions to actually test the values.

Suggested change
operationSpan.span.attributes['graphql.operation.name'] === 'test';
operationSpan.span.attributes['graphql.operation.type'] === 'query';
operationSpan.span.attributes['hive.graphql.error.count'] === 1;
expect(operationSpan.span.attributes['graphql.operation.name']).toBe('test');
expect(operationSpan.span.attributes['graphql.operation.type']).toBe('query');
expect(operationSpan.span.attributes['hive.graphql.error.count']).toBe(1);

Copilot uses AI. Check for mistakes.


const codes = [];
for (const error of result) {
if (error.extensions.code) {
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential runtime error if error.extensions is undefined. Should check if error.extensions exists before accessing the code property.

Suggested change
if (error.extensions.code) {
if (error.extensions && error.extensions.code) {

Copilot uses AI. Check for mistakes.

document,
operationName || undefined,
);
} catch {}
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty catch block suppresses all errors silently. Consider logging the error or adding a comment explaining why errors should be ignored here.

Suggested change
} catch {}
} catch (err) {
// Failed to get operation AST from document; log error for debugging.
console.error('Error in getOperationFromDocument:', err);
}

Copilot uses AI. Check for mistakes.

import {
getOperationASTFromDocument,
isAsyncIterable,
memoize2,
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The memoize2 import is added but never used in this file. This unused import should be removed.

Suggested change
memoize2,

Copilot uses AI. Check for mistakes.

@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-hive/gateway 2.1.10-alpha-1840765d92a74f7cc279061328104c5ea7b4df49 npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 2.0.15-alpha-1840765d92a74f7cc279061328104c5ea7b4df49 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-opentelemetry 1.0.12-alpha-1840765d92a74f7cc279061328104c5ea7b4df49 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 2.0.13-alpha-1840765d92a74f7cc279061328104c5ea7b4df49 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 2.1.9-alpha-1840765d92a74f7cc279061328104c5ea7b4df49 npm ↗︎ unpkg ↗︎

@EmrysMyrddin EmrysMyrddin force-pushed the repro/otel/bad-validation-error-handling branch from 1a5b4c6 to eab949a Compare September 26, 2025 15:38
@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (Binary for Linux-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (Binary for macOS-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (Binary for Linux-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (Binary for Windows-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (Node Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.1.6-alpha-d1575658d7a2e204c8610225399ba836a8f3c9ac

@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (Bun Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.1.6-alpha-d1575658d7a2e204c8610225399ba836a8f3c9ac-bun

@theguild-bot
Copy link
Collaborator

theguild-bot commented Sep 26, 2025

🚀 Snapshot Release (Binary for macOS-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@EmrysMyrddin EmrysMyrddin marked this pull request as draft September 26, 2025 15:56
@n1ru4l n1ru4l self-requested a review October 8, 2025 13:21
Copy link
Contributor

@n1ru4l n1ru4l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works!

@EmrysMyrddin EmrysMyrddin marked this pull request as ready for review October 8, 2025 17:23
@EmrysMyrddin EmrysMyrddin force-pushed the repro/otel/bad-validation-error-handling branch from d157565 to 1840765 Compare October 9, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants